package com.bjpower.models;

import com.bjpower.common.enums.SysCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String message;
    private Object data;

    public static Result ok(Object data)
    {
        Result result = new Result();
        result.setCode(1000);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }

    public static Result ok()
    {
        Result result = new Result();
        result.setCode(1000);
        result.setMessage("操作成功");
        result.setData("");
        return result;
    }

    public static Result error(SysCode sysCode){
        Result result = new Result();
        result.setCode(sysCode.getCode());
        result.setMessage(sysCode.getMessage());
       return result;
    }
}
